package l1j.server.server.datatables;

import java.sql.Connection;
import java.sql.PreparedStatement;
import java.sql.ResultSet;
import java.sql.SQLException;
import java.util.ArrayList;
import java.util.List;

import l1j.server.L1DatabaseFactory;
import l1j.server.server.utils.SQLUtil;

// samtang 新增
public class DropBroadTable {

	private static DropBroadTable _instance;
	
	private final List<Integer> _itemIdList = new ArrayList<Integer>();
	
	public static DropBroadTable getInstance() {
		if (_instance == null) {
			_instance = new DropBroadTable();
		}
		return _instance;
	}
	
	private DropBroadTable() {
		load();
	}

	private void load() {
		Connection con = null;
		PreparedStatement pstm = null;
		ResultSet rs = null;
		try {

			con = L1DatabaseFactory.getInstance().getConnection();
			pstm = con.prepareStatement("SELECT * FROM drop_broad");
			rs = pstm.executeQuery();
			fillTable(rs);
		}
		catch (SQLException e) {
			//_log.log(Level.SEVERE, "error while creating armor_set table", e);
		}
		finally {
			SQLUtil.close(rs);
			SQLUtil.close(pstm);
			SQLUtil.close(con);
		}
	}

	private void fillTable(ResultSet rs) throws SQLException {
		while (rs.next()) {
			_itemIdList.add(rs.getInt("item_id"));
		}
	}
	
	public List<Integer> getDropBroadList() {
		return _itemIdList;
	}
}
